const menus = [
  {
      name: 'menu1',
      hidden: false,
      children: [
          {
              name: 'menu1-1',
              hidden: false,
          },
          {
              name: 'menu1-2',
              hidden: () => {return Math.random() * 10 > 5},
          },
      ]
  },
  {
      name: 'menu2',
      hidden: true,
  }
]

function hiddenObj(nemu){
  const arr=[]
  nemu.forEach(element => {
    if (element.children){
      element.children = hiddenObj(element.children)
      console.log(element.children,27);
    }
    if(typeof element.hidden === 'function'){
      element.hidden = element.hidden()
    }
    if(!element.hidden){
      arr.push(element)
    }
  });
  return arr
}
console.log(hiddenObj(menus));